//
//  LoadingViewManager.m
//  ZYTS-iPhone
//
//  Created by yuzhou on 13-3-1.
//  Copyright (c) 2013年 wzyk. All rights reserved.
//

#import "LoadingViewManager.h"

@implementation LoadingViewManager

static LoadingViewManager *loadingViewManager;

+ (LoadingViewManager *)defaultManager
{
    if (loadingViewManager == nil) {
        loadingViewManager = [[LoadingViewManager alloc] init];
    }
    return loadingViewManager;
}

- (void)showLoadingView
{
    if (loadingView.superview != nil) {
        return;
    }
    UIWindow *window = [[UIApplication sharedApplication] keyWindow];
    if (loadingView == nil) {
        loadingView = [[ABSpringLoadingView alloc] initWithFrame:[window bounds]];
        loadingView.delegate = self;
    }
    [window addSubview:loadingView];
}

- (void)removeLoadingView
{
    if (loadingView.superview != nil) {
        [loadingView removeFromSuperview];
        [loadingView release];
        loadingView = nil;
    }
}

- (void)userClose
{
    [self removeLoadingView];
}

@end
